/*
 * v1.1 by tonydon site:txdnet.cn
 * netbeansIDE 7.1
 */
package cn.txdnet.txweb.utils;
import cn.txdnet.txcms.domain.Manager;
import javax.servlet.http.HttpServletRequest;
import txdnet.util.Context;
/**
 *
 * @author txdnet
 */
public final class SessionUtil {
    
//    得到管理员会话对象
    public static Manager getManager(HttpServletRequest req){
        return (Manager)Context.getSessionAttribute(req, Constants.SN_MGR);
    }
    
//    设置管理员对象
    public static void setManager(HttpServletRequest req, Manager m){
        Context.setSessionAttribute(req, Constants.SN_MGR, m);
    }
    
//    移除管理员会话
    public static void removeManager(HttpServletRequest req){
        Context.setSessionAttribute(req, Constants.SN_MGR, null);
    }
    
//    得到验证码会话对象, 并移除该对象
    public static String getVcodeAndRemove(HttpServletRequest req){
        String vcode = (String)Context.getSessionAttribute(req, Constants.SN_VCODE);
                               Context.setSessionAttribute(req, Constants.SN_VCODE, null);
        return vcode;
    }
}
